import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";

@Index("account", ["account"], { unique: true })
@Index("openid", ["openid"], { unique: true })
@Index("unionid", ["unionid"], { unique: true })
@Entity("merchant", { schema: "frog_charge" })
export class Merchant {
  @PrimaryGeneratedColumn({ type: "int", name: "merchant_id", unsigned: true })
  merchantId: number;

  @Column("varchar", { name: "name", comment: "名称", length: 20 })
  name: string;

  @Column("varchar", {
    name: "account",
    unique: true,
    comment: "账号",
    length: 15,
  })
  account: string;

  @Column("char", { name: "password", comment: "密码", length: 32 })
  password: string;

  @Column("varchar", { name: "contacts", comment: "联系人", length: 10 })
  contacts: string;

  @Column("varchar", { name: "phone", comment: "联系电话", length: 11 })
  phone: string;

  @Column("varchar", { name: "salt", length: 20 })
  salt: string;

  @Column("tinyint", {
    name: "status",
    comment: "0:禁用，1：正常",
    unsigned: true,
    default: () => "'0'",
  })
  status: number;

  @Column("varchar", { name: "nickname", comment: "昵称", length: 30 })
  nickname: string;

  @Column("varchar", { name: "avatar", comment: "头像", length: 60 })
  avatar: string;

  @Column("varchar", {
    name: "openid",
    nullable: true,
    unique: true,
    comment: "openid",
    length: 64,
  })
  openid: string | null;

  @Column("varchar", {
    name: "unionid",
    nullable: true,
    unique: true,
    comment: "unionid",
    length: 64,
  })
  unionid: string | null;

  @Column("varchar", { name: "session_key", length: 32 })
  sessionKey: string;

  @Column("int", {
    name: "create_time",
    comment: "注册时间",
    unsigned: true,
    default: () => "'0'",
  })
  createTime: number;

  @Column("int", {
    name: "update_time",
    comment: "更新",
    unsigned: true,
    default: () => "'0'",
  })
  updateTime: number;

  @Column("int", {
    name: "last_login_time",
    comment: "最后登录时间",
    unsigned: true,
    default: () => "'0'",
  })
  lastLoginTime: number;
}
